import os, sys, boto3

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.extend([BASE_DIR,])

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "thesite.settings")

import django
from django.conf import settings

django.setup()

if __name__ == '__main__':
    sts_client = boto3.client('sts',
                              aws_access_key_id=settings.OSS_AK,
                              aws_secret_access_key=settings.OSS_SK,
                              endpoint_url=settings.OSS_ENDPOINT,
                              region_name=settings.OSS_REGION,
                              )
    response = sts_client.assume_role(
        # 临时委托授权的CRN
        RoleArn=settings.OSS_ARN,
        RoleSessionName='Bobsadasssssssssssadasd', # should be random?
        DurationSeconds=3600
    )
    print("获取临时访问的aksk：")
    print(response)